home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / sipp / libsipp / bozo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-03  |  1.7 KB  |  65 lines

  1. /**
  2.  ** sipp - SImple Polygon Processor
  3.  **
  4.  **  A general 3d graphic package
  5.  **
  6.  **  Copyright Equivalent Software HB  1992
  7.  **
  8.  ** This program is free software; you can redistribute it and/or modify
  9.  ** it under the terms of the GNU General Public License as published by
  10.  ** the Free Software Foundation; either version 1, or any later version.
  11.  ** This program is distributed in the hope that it will be useful,
  12.  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  ** GNU General Public License for more details.
  15.  ** You can receive a copy of the GNU General Public License from the
  16.  ** Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  **/
  18.  
  19. /**
  20.  ** bozo.c - Bozo shader: color objects a la Bozo the clown.
  21.  **/
  22.  
  23. #include <math.h>
  24. #include <stdio.h>
  25.  
  26. #include <sipp.h>
  27. #include <noise.h>
  28. #include <shaders.h>
  29.  
  30.  
  31. extern bool noise_ready;
  32.  
  33. void
  34. bozo_shader(pos, normal, texture, view_vec, lights, bd, color, opacity)
  35.     Vector      *pos;
  36.     Vector      *normal;
  37.     Vector      *texture;
  38.     Vector      *view_vec;
  39.     Lightsource *lights;
  40.     Bozo_desc   *bd;
  41.     Color       *color;
  42.     Color       *opacity;
  43. {
  44.     Vector     tmp;
  45.     Surf_desc  surface;
  46.     double     noiseval;
  47.     int        i;
  48.  
  49.     if (!noise_ready) {
  50.         noise_init();
  51.     }
  52.  
  53.     VecScalMul(tmp, bd->scale, *texture);
  54.     noiseval = noise(&tmp);
  55.  
  56.     i = (noiseval + 1) * bd->no_of_cols / 2.0;
  57.     surface.color    = bd->colors[i];
  58.     surface.ambient  = bd->ambient;
  59.     surface.specular = bd->specular;
  60.     surface.c3       = bd->c3;
  61.     surface.opacity  = bd->opacity;
  62.     basic_shader(pos, normal, texture, view_vec, lights, &surface, 
  63.                  color, opacity);
  64. }
  65.